package com.webank.weideagroup2.web.ctrl;


import com.webank.weideagroup2.bean.Car;
import com.webank.weideagroup2.bean.Record;
import com.webank.weideagroup2.bean.ResultBean;
import com.webank.weideagroup2.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/api/car")
public class CarController {

    @Autowired
    private CarService carService;

    @GetMapping(value = "/{carId}")
    public ResultBean getCarInfo(@PathVariable String carId, @RequestParam(name = "type", required = false, defaultValue = "0") int type) throws Exception {
        Car car = new Car();
        car.setVIN(carId);
        List<Record> resultBeanList = carService.getCarInfo(car, type);

        ResultBean resultBean = new ResultBean();
        resultBean.setData(resultBeanList);
        resultBean.setStatus(0);
        resultBean.setMsg("查询成功");

        return resultBean;

    }


}
